<template>
  <div>
    <el-dialog title="添加规则"
               :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="规则名称"
                      :label-width="formLabelWidth">
          <el-input v-model="form.name"
                    autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="规则值"
                      :label-width="formLabelWidth">
          <el-input v-model="form.value"
                    autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="请选择触发条件"
                      :label-width="formLabelWidth">
          <el-select v-model="form.code"
                     placeholder="请选择触发条件">
            <el-option label="主动"
                       value="DATA"></el-option>
            <el-option label="被动"
                       value="DATE"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer"
           class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary"
                   @click="submit()">确 定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { insert } from '@/api/rule'
export default {
  data () {
    return {
      dialogFormVisible: false,
      form: {
        type: 'COUPON'
      },
      formLabelWidth: '120px'
    }
  },
  methods: {
    open () {
      this.dialogFormVisible = true
    },
    submit () {
      insert(this.form).then((res) => {
        this.$message({
          message: res.msg,
          type: 'success',
          duration: 5 * 1000
        })
        this.$parent.$refs.tab.list();
        this.dialogFormVisible = false

      })
    }
  }

}
</script>

<style lang="sass" scoped>
</style>